{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="ID|姓名|手机号"/>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_school" lay-search="" id="user_school"  lay-filter="province">
                                <option value="">---- 请选择琴行 ----</option>
                                {foreach name="panio" item="vo"}
                                <option value="{$vo.pa_id}" >{$vo.pa_name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sex">
                                <option value="">---- 不限性别 ----</option>
                                <option value="1">男</option>
                                <option value="2">女</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-2">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.href('{:url('teacherAdd')}');">
                            <i class="fa fa-plus"></i> 新增教师账号
                        </button>
                    </div>
                </div>
                <div class="col-sm-2">
                    <div class="input-group">
                        <button  class="btn btn-primary m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-check"></i> 查看详情 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a href="javascript:;" class="layuiBtn" data-type="comments"><i class="fa fa-info"></i>收到的评价</a></li>
                            <li><a href="javascript:;" class="layuiBtn" data-type="planinfos"><i class="fa fa-info"></i>课程表</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="user_status">
                    {{# if(d.user_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.user_status == 2){ }}
                    已冻结
                    {{# } }}
                    </script>
                    <script type="text/html" id="user_gender">
                    {{# if(d.user_gender == 1){ }}
                    男
                    {{# } }}
                    {{# if(d.user_gender == 2){ }}
                    女
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down')}','确定冻结吗?')" class="btn btn-primary btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('memberEdit')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('deluser')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Teacher/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
//            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'radio', fixed: 'left'}
                , {type:'numbers', width: 60, title: '序号'}
                , {field: 'user_id', width: 60, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 130, title: '昵称', align: 'center'}
                , {field: 'user_image', width: '', title: '头像', align: 'center', templet: '#imgTpl'}
                , {field: 'user_phone', width: 120, title: '手机号码', align: 'center'}
                , {field: 'axes', width: 120, title: '喜欢的乐器', align: 'center'}
                , {field: 'panios', width: '', title: '所属琴行', align: 'center'}
                , {field: 'user_gender', width: 90, title: '性别', align: 'center',toolbar: '#user_gender'}
                , {field: 'user_birthday', width: 90, title: '生日', align: 'center'}
                , {field: 'user_sign', width: 90, title: '个人简介', align: 'center'}
                , {field: 'user_time', width: 160, title: '注册时间', align: 'center'}
                , {field: 'user_last_login_time', width: 160, title: '登陆时间', align: 'center'}
                , {field: 'user_status', width: 90, title: '状态', align: 'center',toolbar: '#user_status'}
                , {fixed: 'right', width:240, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            excelAll: function(){
                //导出Excel
                wk.excelAll('',$('.layui-input').serialize(),"{:url('daochu')}");
            },
            comments: function(){
                var userid = getIds();
                if(userid=='' || userid<=0){
                    wk.error('请选择教师','','');
                }else{
                    wk.layer_show('收到的评价', "{:url('comments')}?user_id="+userid);
                }
            },
            planinfos: function(){
                var userid = getIds();
                if(userid=='' || userid<=0){
                    wk.error('课程表','','');
                }else{
                    wk.layer_show('上课记录', "{:url('planinfos')}?user_id="+userid);
                }
            },
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>